type UserQuery = { username: string };
type UserPostData = { message: string };

export default async (type: string, { query }: { query: UserQuery }) => {
  const { username } = query;
  return {
    type,
    username,
    message: `Hello Modern.js`,
  };
};

export const post = async (
  type: string,
  { query, data }: { query: UserQuery; data: UserPostData },
) => {
  const { username } = query;
  const { message } = data;
  return Promise.resolve({
    type,
    username,
    message: `Hello Modern.js. Your message: ${message}`,
  });
};
